package com.gdut.simple.view.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.gdut.simple.R;
import com.gdut.simple.data.entity.User;
import com.gdut.simple.view.activity.user.CommentActivity;
import com.gdut.simple.view.activity.user.FavoritesActivity;
import com.gdut.simple.view.activity.user.FollowActivity;
import com.gdut.simple.view.basic.AbsBasicFragment;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class UserOtherFragment extends AbsBasicFragment {

    private User user;

    public static UserOtherFragment newInstance(User user) {
        UserOtherFragment userInfoFragment = new UserOtherFragment();
        Bundle bundle = new Bundle();
        bundle.putParcelable("user", user);
        userInfoFragment.setArguments(bundle);
        return userInfoFragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        user = getArguments().getParcelable("user");
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_user_other, container, false);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void fetchData() {
    }

    @OnClick(R.id.id_user_comment_button)
    void gotoComment() {
        Intent intent = new Intent(getActivity(), CommentActivity.class);
        Bundle bundle = new Bundle();
        bundle.putParcelable("user", user);
        bundle.putString("objectId", user.getObjectId());
        intent.putExtras(bundle);
        startActivity(intent);
    }

    @OnClick(R.id.id_user_follow_button)
    void gotoFollow() {
        Intent intent = new Intent(getActivity(), FollowActivity.class);
        Bundle bundle = new Bundle();
        bundle.putParcelable("user", user);
        bundle.putString("objectId", user.getObjectId());
        intent.putExtras(bundle);
        startActivity(intent);
    }

    @OnClick(R.id.id_user_collect_button)
    void gotoCollect() {
        Intent intent = new Intent(getActivity(), FavoritesActivity.class);
        Bundle bundle = new Bundle();
        bundle.putParcelable("user", user);
        bundle.putString("objectId", user.getObjectId());
        intent.putExtras(bundle);
        startActivity(intent);
    }
}
